<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>添加新的题目</title>
    <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/bootstrap-table.css" rel="stylesheet"/>
    <link href="css/bootstrap-select.min.css" rel="stylesheet"/>
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>


        .form-signin {
            max-width: 330px;
            padding: 15px;
            margin: 0 auto;
        }

        .form-signin .form-signin-heading,
        .form-signin {
            margin-bottom: 10px;
        }


        .form-signin .form-control {
            position: relative;
            height: auto;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 10px;
            font-size: 16px;
        }
        .form-signin .form-control:focus {
            z-index: 2;
        }


    </style>
</head>
<body>
<!--导航栏开始-->
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">预热班学员管理系统—习题添加</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="/rsm/SubjectManager.html">返回</a></li>
                    <li></li>
                </ul>
            </ul>
        </div>

    </div>
</nav>
<!--导航栏结束-->
<div class="container">
    <button class="btn btn-default" onclick="opendaor()">
        <i class="glyphicon glyphicon-upload"></i>
    </button>
    <form class="form-signin" method="post" action="/rsm/subject/addSubject.do">
        <h2 class="form-signin-heading">选择问题所属的章节</h2>
        <br>
        <select id="slpk" class="selectpicker" name="id"></select>
        <br>
        <br>
        <div class="form-group">
            <label>需要添加的问题</label>
            <textarea class="form-control" rows="3" name="subContent"></textarea>
        </div>
        <br>
        <button class="btn btn-lg btn-primary btn-block" type="submit">提交</button>
    </form>

</div> <!-- /container -->

<!-- 导入模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    导入试题信息（Excel）
                </h4>
            </div>
            <div class="modal-body">
                <form id="daorForm" role="form" method="post" enctype="multipart/form-data" action="/chisha/subject/importSubject.do">
                    <input  id="fileName" type="file" name="fileName"  />
                    <a href="javascript:void(0)" onclick="importUser()">开始导入</a>
                </form>
            </div>

        </div>
    </div>
</div>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="js/jquery-3.3.1.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-table.js"></script>
<script src="js/bootstrap-table-zh-CN.js"></script>
<script src="js/bootstrap-select.min.js"></script>
<script>
    $(function() {

        //下拉数据加载
        $.ajax({
            type : 'get',
            url : "/rsm/schedule/showall.do",
            dataType : 'json',
            success : function(datas) {//返回list数据并循环获取
                var select = $("#slpk");
                for (var i = 0; i < datas.length; i++) {
                    select.append("<option value='"+datas[i].sid+"'>"
                        + datas[i].sname + "</option>");
                }

                $('.selectpicker').selectpicker('refresh');
            }
        });

        $(".selectpicker").selectpicker({
            noneSelectedText : '请选择'
        });

        $(window).on('load', function() {
            $('.selectpicker').selectpicker('val', '');
            $('.selectpicker').selectpicker('refresh');
        });

        //下拉数据加载
        $.ajax({
            type : 'get',
            url : "/chisha/schedule/showall.do",
            dataType : 'json',
            success : function(datas) {//返回list数据并循环获取
                var select = $("#slpk");
                for (var i = 0; i < datas.length; i++) {
                    select.append("<option value='"+datas[i].sid+"'>"
                        + datas[i].sname + "</option>");
                }
                $('.selectpicker').selectpicker('val', '');
                $('.selectpicker').selectpicker('refresh');
            }
        });
    });

    //            导入文件
    function importUser() {
        var x = $("#fileName").val();
        if(x){
            $("#daorForm").submit();
        }else {
            alert("请选择要导入的文件");
        }

    }

    function opendaor() {
        $('#myModal').modal()
    }
</script>
</body>
</html>
